<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>系统登录 - 超市账单管理系统</title>
    <link rel="stylesheet" href="css/style.css"/>
</head>
<body class="login_bg">
    <section class="loginBox">
        <header class="loginHeader">
            <h1>超市账单管理系统</h1>
        </header>
        <section class="loginCont">
            <form class="loginForm" action="">
                <div class="inputbox">
                    <label for="user">用户名：</label>
                    <input id="userCode" type="text" name="userCode" placeholder="请输入用户名" required/>
                </div>
                <div class="inputbox">
                    <label for="mima">密码：</label>
                    <input id="userPassword" type="password" name="userPassword" placeholder="请输入密码" required/>
                </div>
                <div class="subBtn">
                    <input id="submit" type="submit" value="登录" />
                    <input id="reset" type="reset" value="重置"/>
                </div>
            </form>
        </section>
    </section>
</body>
<script src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#submit").click(function(){
			var userCode = $("#userCode").val();
			var userPassword = $("#userPassword").val();
			$.ajax({
				type:"GET",
				url:"/SSM-1/user/login",
				data:{"userCode":userCode,"userPassword":userPassword},
				dataType:"JSON",
				success:function(data){
					if(data.success){
						alert("登录成功");
						location.href="welcome.html";
					}else{
						alert("登录失败，用户名或密码不正确");
					}
				},
				error:function(data){
					alert("系统异常！");
				}
			});
			return false; //因为按钮是submit，所以即使没有action也会提交到本页面，加个这个就是不要提交
		});
	});
</script>
</html>